package com.iplant.wms.serviceImpl.dao.batch;

import com.iplant.base.po.OutResult;
import com.iplant.base.po.Pagination;
import com.iplant.base.utils.annotation.dao.DBBaseDAO;
import com.iplant.base.utils.sql.BaseDAO;
import com.iplant.basic.service.po.bms.BMSEmployee;
import com.iplant.wms.service.po.batch.MSSBatchRecord;
import lombok.extern.slf4j.Slf4j;

import java.util.*;
import java.util.logging.Logger;

@Slf4j
@DBBaseDAO(MSSBatchRecord.class)
public class MSSBatchRecordDAO extends BaseDAO {

    private static MSSBatchRecordDAO Instance = null;

    private MSSBatchRecordDAO() {
        super("");
        this.Init();
    }

    public static MSSBatchRecordDAO getInstance() {
        if (Instance == null) {
            Instance = new MSSBatchRecordDAO();
        }
        return Instance;
    }


    public List<MSSBatchRecord> MSS_SelectBatchRecordList(BMSEmployee wLoginUser, List<String> wBatchNoList, int wMaterialID, Pagination wPagination, OutResult<Integer> wErrorCode) {

        Map<String, Object> wParams = new HashMap<>();
        wParams.put("MaterialID", wMaterialID);
        return this.SelectPOList(wLoginUser, wBatchNoList, wParams, wPagination, wErrorCode);
    }

    public List<MSSBatchRecord> MSS_SelectBatchRecordList(BMSEmployee wLoginUser, int wMaterialID, Pagination wPagination, OutResult<Integer> wErrorCode) {

        Map<String, Object> wParams = new HashMap<>();
        wParams.put("MaterialID", wMaterialID);
        return this.SelectPOList(wLoginUser, wParams, wPagination, wErrorCode);
    }


    public int MSS_DeleteByID(BMSEmployee wLoginUser, int wID, OutResult<Integer> wErrorCode) {

        try {
            Map<String, Object> wParams = new HashMap<>();
            wParams.put("ID", wID);
            return this.Delete(wParams);
        } catch (Exception ex) {
            log.error("MSS_DeleteByID", ex);
        }
        return 0;
    }

}
